package cn.wolfcode.luowowo.query;

import cn.wolfcode.luowowo.common.query.QueryObject;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;


/**
 * Created by LENOVO on 2019/8/17.
 */
@Getter
@Setter
public class SearchQueryObject extends QueryObject {
    public  static final  int CONDITION_TYPE_ABROAD=0; //国外
    public  static final  int CONDITION_TYPE_UN_ABROAD=1;  //国内

    public  static final  int CONDITION_TYPE_THEME=2;  //主题



    public  static final  int CONDITION_TYPE_ALL=-1;  //所有

    public  static final  int CONDITION_TYPE_DEST=0;//目的地
    public  static final  int CONDITION_TYPE_STRATEGY=1;//攻略
    public  static final  int CONDITION_TYPE_TRAVEL=2;//游记
    public  static final  int CONDITION_TYPE_USER=3;//人



    private int type=-1;//条件类别，国内 国外 主题

    private Long typeValue=-1L;

    private String orderBy="viewnum";

    public Pageable getPageable(){

        return PageRequest.of(super.getCurrentPage()-1,super.getPageSize()
        , Sort.by(Sort.Direction.DESC,orderBy));
    }

    public Pageable getPageableNoSort(){

        return PageRequest.of(super.getCurrentPage()-1,super.getPageSize());
    }
}
